package demo1;

public class Computer {//电脑
    //打开电脑
    public void powerOn() {
        System.out.println("打开电脑");
    }

    //使用电脑
    public void useDevice(IUSB iusb) {
        //开启服务
        iusb.openDevice();

        if(iusb instanceof Mouse) {
            Mouse mouse = (Mouse)iusb;
            mouse.click();
        }else if(iusb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard)iusb;
            keyBoard.inPut();
        }
            //关闭服务
            iusb.closeDevice();
    }

    //关闭电脑
    public void OffOn() {
        System.out.println("关闭电脑");
    }
}
